home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / mapzzzmenus.py < prev    next >
Text File  |  2004-01-05  |  4KB  |  119 lines

  1. ########################################################
  2. #
  3. #               Submenu promote/demote Plugin
  4. #                      v1, Dec 27, 2000
  5. #                     works with Quark 6.1
  6. #
  7. #
  8. #                by tiglari@hexenworld.net     
  9. #
  10. #   You may freely distribute modified & extended versions of
  11. #   this plugin as long as you give due credit to tiglari &
  12. #   Armin Rigo. (It's free software, just like Quark itself.)
  13. #
  14. #   Please notify bugs & possible improvements to
  15. #   tiglari@planetquake.com
  16. #  
  17. #
  18. ##########################################################
  19.  
  20. #$Header: /cvsroot/quark/runtime/plugins/mapzzzmenus.py,v 1.2 2003/01/31 20:15:04 tiglari Exp $
  21.  
  22.  
  23. Info = {
  24.    "plug-in":       "Menu Fixup",
  25.    "desc":          "Promoting & Demoting submenus",
  26.    "date":          "Dec 27, 2000",
  27.    "author":        "tiglari",
  28.    "author e-mail": "tiglari@hexenworld.net",
  29.    "quark":         "Version 6.1" }
  30.  
  31. import quarkx
  32. import quarkpy.mapmenus
  33. import quarkpy.mapentities
  34. import quarkpy.qmenu
  35. from quarkpy.maputils import *
  36.  
  37. #
  38. # This plugin must run last, the name is intended to promote this, but
  39. #  if it doesn't work, plugins finding the 'texpop' and 'tagpop' popup
  40. #  menus need to be imported first:
  41. #
  42. import mapcaulk
  43.  
  44. #
  45. # There must be a way to do this with greater generality.
  46. #  But there's also fiddly bits
  47. #
  48. def facemenu(o, editor, oldfacemenu = quarkpy.mapentities.FaceType.menu.im_func):
  49.     menu = oldfacemenu(o, editor)
  50.  
  51.     promote = quarkx.setupsubset(SS_MAP, "Options")["Texpop"]
  52.  
  53.     def promoteClick(m):
  54.         quarkx.setupsubset(SS_MAP, "Options")["Texpop"]="1"
  55.          
  56.     def demoteClick(m):
  57.         quarkx.setupsubset(SS_MAP, "Options")["Texpop"]="0"
  58.  
  59.     if promote=="1":
  60.         promoteItem = qmenu.item('Demote Texture',demoteClick, "|Texture menu items get demoted to submenu")
  61.     else:
  62.         promoteItem = qmenu.item('Promote texture',promoteClick, "|Texture menu subitems get promoted onto main vertex menu")
  63.  
  64.  
  65.     promoteWrap = quarkx.setupsubset(SS_MAP, "Options")["Wrappop"]
  66.  
  67.     def promoteWrapClick(m):
  68.         quarkx.setupsubset(SS_MAP, "Options")["Wrappop"]="1"
  69.          
  70.     def demoteWrapClick(m):
  71.         quarkx.setupsubset(SS_MAP, "Options")["Wrappop"]="0"
  72.  
  73.     if promoteWrap=="1":
  74.         promoteWrapItem = qmenu.item('Demote Wrapping',demoteWrapClick, "|Wrapping menu items get demoted to submenu")
  75.     else:
  76.         promoteWrapItem = qmenu.item('Promote Wrapping',promoteWrapClick, "|Wrapping submenu items get promoted onto main vertex menu")
  77.  
  78.  
  79.     texpop = findlabelled(menu,'texpop')
  80.     texpop.items.append(promoteItem)
  81.     wrappop = findlabelled(texpop.items,'wrappopup')
  82.     wrappop.items.append(promoteWrapItem)
  83.     if promoteWrap=="1":
  84.         wrapind = texpop.items.index(wrappop)
  85.         #
  86.         # Fix up texts
  87.         #
  88.         for item in wrappop.items:
  89.             #
  90.             # The stuff below the separator is options
  91.             #  that don't need a prefix to be intelligible
  92.             #
  93.             if item == qmenu.sep:
  94.                 break
  95.             try:
  96.                 item.text = "Wrap texture "+item.text
  97.             except (AttributeError):
  98.                 pass
  99.         #
  100.         # Put wrap items after promote texture
  101.         #
  102.         texpop.items.remove(wrappop)
  103.         texpop.items=texpop.items+[qmenu.sep]+wrappop.items
  104.     if promote=="1":
  105.         texind = menu.index(texpop)
  106.         menu[texind:texind+1]=texpop.items
  107.     return menu
  108.  
  109. quarkpy.mapentities.FaceType.menu = facemenu
  110.  
  111. # ----------- REVISION HISTORY ------------
  112. #$Log: mapzzzmenus.py,v $
  113. #Revision 1.2  2003/01/31 20:15:04  tiglari
  114. #add import to get new mapcaulk.py to load first
  115. #
  116. #Revision 1.1  2001/05/29 10:13:21  tiglari
  117. #kickoff
  118. #
  119.